﻿namespace LinkedTU.Data.Extensions
{
    using System;
    using System.Collections;
    using System.Data.Entity;

    public static class EntityFrameworkExtensions
    {
        public static IEnumerable AddRange<T>(this IDbSet<T> iDbSet, IEnumerable entities)
            where T : class
        {
            var dbSet = iDbSet as DbSet<T>;

            if (dbSet == null)
            {
                throw new InvalidOperationException("The IDbSet is not DbSet and doesn't contain method AddRange");
            }

            return dbSet.AddRange(entities);
        }

    }
}
